package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Borrow implements Ioperation{
    @Override
    public void work(BookList bookList) {
        Scanner scan = new Scanner(System.in);
        System.out.println("输入你要借阅的图书：");
        String bookName = scan.nextLine();

        int cur = bookList.getCur();
        for (int i = 0; i < cur; i++) {
            Book book = bookList.getBooks(i);
            if(book.getName().equals(bookName)){
                if(book.isBorrowed() == false){
                    System.out.println("成功被你借走！！！");
                    book.setBorrowed(true);
                }else{
                    System.out.println("该书已被借走......");
                }
                return;
            }
        }
        System.out.println("没有该书......");
    }
}
